<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>美兰数据文化馆与图书馆</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/public.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/images/favicon.ico"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="inventorySequence" lay-filter="inventorySequences"></table>
            <div id="laypage"></div>
        </div>
    </div>
</div>
<input type="hidden" id="curnum" value="1">
<script type="text/html" id="states">
    {{#  if(d.state== '0'){}}
    <button class="layui-btn layui-btn-primary layui-btn-xs">未盘到</button>
    {{#  } else {}}
    <button class="layui-btn layui-btn-xs">盘到</button>
    {{#  } }}
</script>
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script>
    function child(sequence) {
        layui.use(['form', 'laydate','laypage','table'], function () {
            var $ = layui.$
                , form = layui.form
                , laydate = layui.laydate
                , layer = layui.layer,
                laypage=layui.laypage,
                table=layui.table;

            var limitcount = 10;
            table.render({
                elem: '#inventorySequence'
                , url: "<%=request.getContextPath()%>/rest/inventory/inventorySequence"
                ,title:"盘点列表",
                height: 'full-210'
                , page: false
                , limit: limitcount,
                where:{"sequence":sequence}
                , text: {
                    none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
                },
                toolbar: '#',
                defaultToolbar: ['filter', 'print']
                , cols: [[
                    // {type: 'checkbox'}
                    {field: 'number', title: 'ID', width: 70, sort: true,fixed:'left'}
                    , {field: 'sequence', title: '单据编号',sort: true}
                    , {field: 'ecpcode', title: 'EPC标签',width:235,sort: true}
                    , {field: 'name', title: '物资名称',sort: true}
                    , {field: 'responsible', title: '使用人员',sort: true}
                    , {field: 'state', title: '盘点状态',templet: '#states',sort: true}
                    , {field: 'createby', title: '操作人员',sort: true}
                    , {field: 'lastmodifyby', title: '操作时间',sort: true}
                ]],
                done: function (res, curr, count) {
                    var curnum = $("#curnum").val();
                    laypage.render({
                        elem: 'laypage'
                        ,first: '首页'
                        ,last: '尾页'
                        ,groups:5
                        , count: count
                        , curr: curnum
                        , limit: limitcount
                        , layout: ['prev', 'page', 'next', 'skip', 'count','limit']
                        , limits:[10,15,20]
                        , jump: function (obj, first) {
                            if (!first) {
                                curnum = obj.curr;
                                $("#curnum").val(curnum)
                                limitcount = obj.limit;
                                table.reload('inventorySequence', { //表格的id
                                    where: {
                                        page: curnum,
                                        limit:limitcount
                                    }
                                })
                            }
                        }
                    })
                }
            });

        });
    }
</script>
</body>
</html>